<%@page import="com.kaishengit.dao.CarItem"%> 
<%@page import="com.kaishengit.entity.Prod"%>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="top.jsp" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <title>我的购物车</title>
  </head>
  <body>
  	
	<%
		float total = 0f;
		List<CarItem> list = (List<CarItem>)session.getAttribute("shopCar");
		if(list == null || list.isEmpty()) {
	%>
		<div style="padding-top:100px;font-size:30px">
			您的购物车还是空的，快去<a href="prod.jspx">购物</a>吧！
		</div>
			
	 <% 
		return;}else{
	 %>
	 	<div style="float:right;padding-top:50px">
          	<a href="prod.jspx" style="font-size:36px">←继续购物</a>
	    </div>
		<div class="container" style="padding-top:100px">
			<div>
				<table class="table table-striped"  >
			<thead>
				<tr>
			 		<th>商品名称</th>
			 		<th>商品单价</th>
			 		<th>商品数量</th>
			 		<th>商品总价</th>
			 		<th>操作</th>
		 		</tr>	
			</thead>
			<%
		 	for(CarItem item : list) {
		 		total += item.getTotal();
		    %>
				
			<tr>
			  	<td><%=item.getProd().getProdname() %></td>
			  	<td>￥<%=item.getProd().getPrice() %></td>
			  	<td>
			  		<form action="prod.jspx?m=updatenum" method="post">
			  			<input type="hidden" name="id" value="<%=item.getProd().getId()%>">
			  			<input type="text" name="num" style="width:40px;height:20px" value="<%=item.getNum()%>">
			  			<input type="submit" value="修改">
			  		</form>
			  	</td>
			  	<td>￥<%=item.getTotal() %></td>
			  	<td>
			  		<a href="prod.jspx?m=delcar&id=<%=item.getProd().getId()%>">删除</a> 
			  	</td>
		  </tr>
		  <%} }%>
		</table>
			</div>
		<div style="float:right">
			<h3>总共需要支付￥<%=total%>元</h3><hr/>
	 		<div style="float:right">	
	 			<a href="prod.jspx?m=order" style="font-size:24px">结算</a>
			</div>
		</div>
		
	</div>	 

  </body>
</html>
